# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python


class Recipe(custom.GStreamer):
    name = 'gst-plugins-bad-1.0'
    config_sh = 'sh ./autogen.sh --noconfigure && ./configure'
    configure_options = '--enable-static --disable-introspection --disable-gsm \
        --disable-examples --disable-festival \
        --disable-videomaxrate --disable-bz2 --disable-libde265 \
        --disable-linsys --disable-fbdev --disable-apexsink \
        --disable-celt --disable-curl --disable-dc1394 --disable-directfb \
        --disable-dirac --disable-faac --disable-flite --disable-gme \
        --disable-ladspa --disable-lv2 --disable-mimic --disable-modplug \
        --disable-mpeg2enc --disable-mplex --disable-musepack --disable-mythtv \
        --disable-neon --disable-ofa --disable-openal --disable-opencv \
        --disable-pvr --disable-sdl --disable-sndfile \
        --disable-teletextdec --disable-timidity \
        --disable-vdpau --disable-voamrwbenc --disable-wildmidi \
        --disable-xvid --disable-zbar --disable-sdi --disable-hls --disable-qt \
        --enable-decklink'
    # Explicitly enable plugins
    remotes = {'origin': 'git://anongit.freedesktop.org/gstreamer/gst-plugins-bad'}
    commit = 'c28f2f6ce82ff44bf4749c9f2376c21980e58af3'
    deps = ['gstreamer-1.0', 'gst-plugins-base-1.0', 'zlib', 'openh264', 'opus',
            'libsrtp', 'openssl', 'graphene']
    use_system_libs = True

    files_lang = ['gst-plugins-bad-1.0']

    files_libs = ['libgstcodecparsers-1.0', 'libgstgl-1.0', 'libgstbadbase-1.0', 'libgstbadvideo-1.0', 'libgstbadallocators-1.0']

    files_plugins_devel = [
        'include/gstreamer-1.0/gst/gl',
        'lib/gstreamer-1.0/include/gst/gl',
        'include/gstreamer-1.0/gst/base',
        'include/gstreamer-1.0/gst/audio',
        'include/gstreamer-1.0/gst/video',
        'include/gstreamer-1.0/gst/codecparsers',
        'include/gstreamer-1.0/gst/interfaces',
        'lib/pkgconfig/gstreamer-plugins-bad-1.0.pc',
        'lib/pkgconfig/gstreamer-gl-1.0.pc',
        'lib/pkgconfig/gstreamer-bad-base-1.0.pc',
        'lib/pkgconfig/gstreamer-bad-audio-1.0.pc',
        'lib/pkgconfig/gstreamer-bad-video-1.0.pc',
        'lib/pkgconfig/gstreamer-codecparsers-1.0.pc',
        'lib/pkgconfig/gstreamer-bad-allocators-1.0.pc'
    ]

    files_plugins_effects = [
             'lib/gstreamer-1.0/libgstinter%(mext)s',
    ]

    files_plugins_effects_devel = [
             'lib/gstreamer-1.0/libgstinter.a', 'lib/gstreamer-1.0/libgstinter.la',
    ]

    files_plugins_codecs = [
             'lib/gstreamer-1.0/libgstopenh264%(mext)s',
             'lib/gstreamer-1.0/libgstvideoparsersbad%(mext)s',
    ]

    files_plugins_codecs_devel = [
             'lib/gstreamer-1.0/libgstopenh264.a', 'lib/gstreamer-1.0/libgstopenh264.la',
             'lib/gstreamer-1.0/libgstvideoparsersbad.a', 'lib/gstreamer-1.0/libgstvideoparsersbad.la',
    ]

    platform_files_plugins_codecs = {
        Platform.ANDROID: [
            ]
    }

    platform_files_plugins_codecs_devel = {
        Platform.ANDROID: [
            ]
    }

    files_plugins_codecs_gpl = [
    ]

    files_plugins_codecs_gpl_devel = [
    ]

    files_plugins_codecs_restricted = [
    ]

    files_plugins_codecs_restricted_devel = [
    ]

    files_plugins_dvd = [
    ]

    files_plugins_dvd_devel = [
    ]

    files_plugins_net = [
             'lib/gstreamer-1.0/libgstsrtp%(mext)s',
             'lib/gstreamer-1.0/libgstdtls%(mext)s',
    ]

    files_plugins_net_devel = [
             'lib/gstreamer-1.0/libgstsrtp.a', 'lib/gstreamer-1.0/libgstsrtp.la',
             'lib/gstreamer-1.0/libgstdtls.a', 'lib/gstreamer-1.0/libgstdtls.la',
    ]

    files_plugins_net_restricted = [
    ]

    files_plugins_net_restricted_devel = [
    ]

    files_plugins_capture = [
    ]

    files_plugins_capture_devel = [
    ]

    platform_files_plugins_capture = {
        Platform.LINUX: [
            ],
        Platform.WINDOWS: [
             'lib/gstreamer-1.0/libgstdirectsoundsrc%(mext)s',
             'lib/gstreamer-1.0/libgstwinks%(mext)s',
            ]
    }

    platform_files_plugins_capture_devel = {
        Platform.LINUX: [
            ],
        Platform.WINDOWS: [
             'lib/gstreamer-1.0/libgstdirectsoundsrc.a', 'lib/gstreamer-1.0/libgstdirectsoundsrc.la',
             'lib/gstreamer-1.0/libgstwinks.a', 'lib/gstreamer-1.0/libgstwinks.la',
            ]
    }

    files_plugins_vis = [
    ]

    files_plugins_vis_devel = [
    ]

    platform_files_plugins_sys = {
        Platform.LINUX: [
             'lib/gstreamer-1.0/libgstopengl%(mext)s',
             'lib/gstreamer-1.0/libgstdecklink%(mext)s',
            ],
        Platform.WINDOWS: [
             'lib/gstreamer-1.0/libgstd3dvideosink%(mext)s',
             'lib/gstreamer-1.0/libgstopengl%(mext)s',
             'lib/gstreamer-1.0/libgstdecklink%(mext)s',
            ],
        Platform.DARWIN: [
             'lib/gstreamer-1.0/libgstapplemedia%(mext)s',
             'lib/gstreamer-1.0/libgstopengl%(mext)s',
             'lib/gstreamer-1.0/libgstdecklink%(mext)s',
            ],
        Platform.IOS: [
             'lib/gstreamer-1.0/libgstapplemedia%(mext)s',
             'lib/gstreamer-1.0/libgstopengl%(mext)s',
            ],
        Platform.ANDROID: [
             'lib/gstreamer-1.0/libgstopensles%(mext)s',
             'lib/gstreamer-1.0/libgstopengl%(mext)s',
            ]
    }

    platform_files_plugins_sys_devel = {
        Platform.LINUX: [
             'lib/gstreamer-1.0/libgstopengl.a', 'lib/gstreamer-1.0/libgstopengl.la',
             'lib/gstreamer-1.0/libgstdecklink.a', 'lib/gstreamer-1.0/libgstdecklink.la',
            ],
        Platform.WINDOWS: [
             'lib/gstreamer-1.0/libgstd3dvideosink.a', 'lib/gstreamer-1.0/libgstd3dvideosink.la',
             'lib/gstreamer-1.0/libgstopengl.a', 'lib/gstreamer-1.0/libgstopengl.la',
             'lib/gstreamer-1.0/libgstdecklink.a', 'lib/gstreamer-1.0/libgstdecklink.la',
            ],
        Platform.DARWIN: [
             'lib/gstreamer-1.0/libgstapplemedia.a', 'lib/gstreamer-1.0/libgstapplemedia.la',
             'lib/gstreamer-1.0/libgstopengl.a', 'lib/gstreamer-1.0/libgstopengl.la',
             'lib/gstreamer-1.0/libgstdecklink.a', 'lib/gstreamer-1.0/libgstdecklink.la',
            ],
        Platform.IOS: [
             'lib/gstreamer-1.0/libgstapplemedia.a', 'lib/gstreamer-1.0/libgstapplemedia.la',
             'lib/gstreamer-1.0/libgstopengl.a', 'lib/gstreamer-1.0/libgstopengl.la',
            ],
        Platform.ANDROID: [
             'lib/gstreamer-1.0/libgstopensles.a', 'lib/gstreamer-1.0/libgstopensles.la',
             'lib/gstreamer-1.0/libgstopengl.a', 'lib/gstreamer-1.0/libgstopengl.la',
            ]
    }

    files_typelibs = [
        'GstGL-1.0',
        ]

    platform_files_codecs_devel = {
        Platform.ANDROID: [
              'share/gst-android/ndk-build',
            ]
    }

    def prepare(self):
        self.append_env['CFLAGS'] = " -Wno-error -DGSTREAMER_GLIB_COCOA_NSAPPLICATION=1 "
        self.append_env['OBJCFLAGS'] = " -Wno-error -DGSTREAMER_GLIB_COCOA_NSAPPLICATION=1 "
        self.append_env['CXXFLAGS'] = " -Wno-error "
        self.append_env['CPPFLAGS'] = " -Wno-error "

        if self.config.platform == Platform.WINDOWS:
            # FIXME: This will almost certainly fail to build on Windows due to
			# https://bugzilla.gnome.org/show_bug.cgi?id=770264
			# See also, -static and gstreamer-1.0-effects.package
			self.deps.remove('webrtc-audio-processing')
			self.files_plugins_effects.remove('lib/gstreamer-1.0/libgstwebrtcdsp%(mext)s')

        if self.config.target_platform != Platform.LINUX:
            self.configure_options += '--disable-gtk-doc '
        if self.config.variants.nodebug:
            self.append_env['CFLAGS'] += ' -DGST_LEVEL_MAX=GST_LEVEL_FIXME'
